import Taro from "@tarojs/taro"
import { View,Text,Image} from '@tarojs/components'
import { useEffect,useState } from 'react'
import {AtIcon } from 'taro-ui'
import { userDetailInfo,getSkillCertificate,getHonorCertificate } from '../../../api/mode'
import { JumpCard } from '../../../components'
import './index.scss'



export default function MyResume(){

  const openid=Taro.getStorageSync(`openid`)
  const [userInfo,setUserInfo]=useState({})
  const [expectPosition,setExpectedPosition]=useState([])//期望职位
  const [workExp,setWorkExp]=useState([])//工作经历
  const [eduBack,setEduBack]=useState([])//教育背景
  const [skillCertificate,setSkillCertificate]=useState([])//技能证书
  const [honorCertificate,setHonorCertificate]=useState([])//荣誉证书


    useEffect(()=>{//初始话数据
    userDetailInfo(Taro.getStorageSync(`openid`)).then(res=>{
      console.log(res.data.data);
      setUserInfo(res.data.data)
      setExpectedPosition(res.data.data.expectedPosition)
      setWorkExp(res.data.data.workExp)
      setEduBack(res.data.data.eduBack)

    })

    getSkillCertificate(openid).then(res=>{//获取技能证书
      console.log(res.data.data);
      setSkillCertificate(res.data.data)
    })

    getHonorCertificate(openid).then(res=>{//获取荣誉证书
      console.log(res.data.data);
      setHonorCertificate(res.data.data)
    })
  }
  ,[openid])


const handleClick=()=>{
  Taro.navigateTo({
    url: '/mine/pages/editorMyResume/editorMyResume'//跳转到编辑我的简历
  })
}


return(
  <View className='frame'>
  <View className='header'>
  <View className='myresumejumpCard'>
  <View className='at-row myresumejumpCardItem'> 
    <View className='at-col '  onClick={handleClick}> 编辑简历 </View>    
    <AtIcon className='at-col' value='chevron-right' size='30' color='#FFF'></AtIcon>
    </View>
      </View>
    {/* <JumpCard context='编辑简历'  handleClick={handleClick} /> */}
  </View>
    <View className='resume' >  
    <View >
    <Text className='intro title'>个人信息</Text>
      <View className='at-row'>
          <View className='at-col at-col-7 '>
          <Image  src={'data:image/png;base64,'+userInfo.photo}  className='userImage'></Image>
          </View>
          <View className='at-col at-col-5'>
          <Text>姓名:{userInfo.name}</Text>
          <Text>性别:{userInfo.sex}</Text>
          <Text>学历:{userInfo.eduDegree}</Text>
          <Text>身高:{userInfo.height}</Text>
          <Text>体重:{userInfo.weight}</Text>
          </View> 
      </View>

        <Text>政治面貌：{userInfo.politicsStatus}</Text>
        <Text>联系方式：{userInfo.phone}</Text>
        <Text>身份证号：{userInfo.idNumber}</Text>
        <Text>出生日期：{userInfo.birthday}</Text>
        <Text>居住地：{userInfo.presentAddr}</Text>
        <Text>所属类型：{userInfo.type}</Text>
        <Text>邮箱：{userInfo.email}</Text>
        <Text>工作经验：{userInfo.workTime}</Text>
        
        <Text className='intro'>个人简介</Text>
        {
          userInfo.selfIntro==='无'
          ?
          <Text style={{height:70}}>无</Text>
          :<Text className='workContent'>{userInfo.selfIntro}</Text>
        }

{/* 期望职位 */}
        <View className='myResumePart'>
        <Text className='intro'>期望职位</Text>
              <View className='at-row'>
                <View className='at-col at-col-3 hopePositionTitle'>地区</View>
                <View className='at-col at-col-3 hopePositionTitle'>职位类别</View>
                <View className='at-col at-col-6 hopePositionTitle'>薪资范围</View>
              </View>

                <View>
                 {//展示初始数据
                expectPosition?
                expectPosition.map((Info,index)=>(
                  <View key={index}>
                    <View className='at-row'>
                      <View className='at-col at-col-3 expectPosition'>
                          {Info.area}
                      </View>
                      <View className='at-col at-col-3 expectPosition'>
                          {Info.type}
                      </View>
                      <View className='at-col at-col-6 expectPosition'> 
                        {Info.minSal}--{Info.maxSal}千元/月
                      </View>
                    </View>
                  </View>
                ))
                :null} 

                </View>
        </View>

{/* 工作经历 */}
        <View className='myResumePart'>
        <Text className='intro'>工作经历</Text>
                    {
                      workExp?
                      workExp.map((Info,index)=>
                      (<View key={index}>
                        <Text>工作经历{index+1}</Text>

                {/* 单位名称 */}
                <View className='at-row'>
                    <View className='at-col at-col-3'>
                        单位名称:
                    </View>
                        <View className='at-col at-col-9' >
                        {Info.dept}
                    </View>
                </View>

                {/* 岗位名称 */}
                <View className='at-row'>
                    <View className='at-col at-col-3'>
                        岗位名称:
                    </View>
                    <View className='at-col at-col-9' >
                          {Info.positionName}
                    </View>
                </View>

                <View className='at-row'>
                  <View className='at-col at-col-3'>工作时间:</View>

                          <View className=' at-col at-col-6' >
                           {`开始`+` `+Info.startTime}
                          </View>
                  </View>


                <View className='at-row'>
                <View className='at-col at-col-3'></View>

                          <View className=' at-col at-col-6' >
                           {`结束`+` `+Info.endTime}
                          </View>
                  </View>

                  <View>
                    <View style={{marginTop:20,marginBottom:20}}>工作内容:</View>
                    <View>
                    <View className='workContent' >
                    {Info.detail}
                    </View>
                    </View>
                  </View>
                      </View>))
                      :null
                    }
            

        </View>


{/* 教育背景 */}
        <View className='myResumePart'>
        <Text className='intro'>教育背景</Text>

                    {
                      eduBack?
                      eduBack.map((Info,index)=>
                      (<View key={index} className='eduBackPart'>
                        <View className='at-row'>
          <View className='at-col at-col-3'>
              教育背景:
          </View>
            <View className='at-col at-col-9'>
            {Info.school}
            </View>
      </View>

     

      <View className='at-row'>
        <View className='at-col at-col-3'>在读时间:</View>

                <View className='at-col at-col-6' >
                  {`开始`+` `+Info.startTime}
                </View>
        </View>


      <View className='at-row'>
      <View className='at-col at-col-3' ></View>

                <View className='at-col at-col-6' >
                  {`结束`+` `+Info.endTime}
                </View>
        </View>

        <View className='at-row'>
          <View className='at-col at-col-3'>
              专业:
          </View>
          <View   className='at-col at-col-9 ' >
            {Info.major}
            </View>
        </View>
          </View>))

      :null
                    }
          
        </View>
      
      <View className='myResumePart'>
      <Text className='intro'>证书</Text>

{/* 获奖证书 */}
        <View>
        <Text >获奖证书:</Text>
                    {
                      honorCertificate?
                      honorCertificate.map((Info,index)=>(
                      <View key={index}>
                       <View className='at-row'>
                       <View className='at-col at-col-5'>
                       {Info.name}
                      </View>
                      <Image className='at-col at-col-7 ' src={'data:image/png;base64,'+Info.photo} /> 
                        
                  
                      </View>
                        
                      </View>))
                      :null
                    }
        </View>
      
{/* 职业技能证书 */}
        <View>
        <Text>职业技能证书:</Text>
        {
                      skillCertificate?
                      skillCertificate.map((Info,index)=>(
                      <View key={index}>
                       <View className='at-row'>
                       <View className='at-col at-col-5'>
                         {Info.name}
                      </View>
                      <Image className='at-col at-col-7 ' src={'data:image/png;base64,'+Info.photo} /> 
                        
                  
                      </View>
                        
                      </View>))
                      :null
                    }
        </View>
      </View>
        
    </View>
  </View>
  </View>
  
  
)
}